﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1003013, 0),
Array("", 1003014, 0),
Array("", 1003015, 0),
Array("", 1003029, 0),
Array("", 1003030, 0),
Array("", 1003038, 0),
Array("", 1003043, 0),
Array("", 1003044, 0),
Array("", 1003047, 0),
Array("", 1003048, 0),
Array("", 1003049, 0),
Array("", 1003050, 0),
Array("", 1003051, 0),
Array("", 1003052, 0),
Array("", 1003053, 0),
Array("", 1003057, 0),
Array("", 1003058, 0),
Array("", 1003059, 0),
Array("", 1003070, 0),
Array("", 1003071, 0),
Array("", 1003072, 0),
Array("", 1003074, 0),
Array("", 1003077, 0),
Array("", 1003078, 0),
Array("", 1003079, 0),
Array("", 1003080, 0),
Array("", 1003082, 0),
Array("", 1003083, 0),
Array("", 1003084, 0),
Array("", 1003089, 0),
Array("", 1003092, 0),
Array("", 1003096, 0),
Array("", 1003103, 0),
Array("", 1003104, 0),
Array("", 1003109, 0),
Array("", 1003120, 0),
Array("", 1003122, 0),
Array("", 1003123, 0),
Array("", 1003130, 0),
Array("", 1003132, 0),
Array("", 1003133, 0),
Array("", 1003135, 0),
Array("", 1003136, 0),
Array("", 1003141, 0),
Array("", 1003146, 0),
Array("", 1003147, 0),
Array("", 1003148, 0),
Array("", 1003149, 0),
Array("", 1003161, 0),
Array("", 1003163, 0),
Array("", 1003170, 0),
Array("", 1003171, 0),
Array("", 1003186, 0),
Array("", 1003187, 0),
Array("", 1003192, 0),
Array("", 1003193, 0),
Array("", 1003194, 0),
Array("", 1003196, 0),
Array("", 1003202, 0),
Array("", 1003203, 0),
Array("", 1003204, 0),
Array("", 1003207, 0),
Array("", 1003208, 0),
Array("", 1003210, 0),
Array("", 1003211, 0),
Array("", 1003214, 0),
Array("", 1003215, 0),
Array("", 1003216, 0),
Array("", 1003217, 0),
Array("", 1003218, 0),
Array("", 1003220, 0),
Array("", 1003221, 0),
Array("", 1003222, 0),
Array("", 1003223, 0),
Array("", 1003226, 0),
Array("", 1003232, 0),
Array("", 1003233, 0),
Array("", 1003234, 0),
Array("", 1003235, 0),
Array("", 1003237, 0),
Array("", 1003238, 0),
Array("", 1003239, 0),
Array("", 1003240, 0),
Array("", 1003241, 0),
Array("", 1003246, 0),
Array("", 1003247, 0),
Array("", 1003249, 0),
Array("", 1003250, 0),
Array("", 1003251, 0),
Array("", 1003252, 0),
Array("", 1003253, 0),
Array("", 1003254, 0),
Array("", 1003255, 0),
Array("", 1003256, 0),
Array("", 1003264, 0),
Array("", 1003265, 0),
Array("", 1003268, 0),
Array("", 1003269, 0),
Array("", 1003271, 0),
Array("", 1003272, 0),
Array("", 1003276, 0),
Array("", 1003277, 0),
Array("", 1003278, 0),
Array("", 1003279, 0),
Array("", 1003352, 0),
Array("", 1003353, 0),
Array("", 1003354, 0),
Array("", 1003355, 0),
Array("", 1003356, 0),
Array("", 1003357, 0),
Array("", 1003358, 0),
Array("", 1003362, 0),
Array("", 1003367, 0),
Array("", 1003368, 0),
Array("", 1003376, 0),
Array("", 1003377, 0),
Array("", 1003386, 0),
Array("", 1003387, 0),
Array("", 1003390, 0),
Array("", 1003392, 0),
Array("", 1003393, 0),
Array("", 1003398, 0),
Array("", 1003399, 0),
Array("", 1003400, 0),
Array("", 1003401, 0),
Array("", 1003402, 0),
Array("", 1003403, 0),
Array("", 1003404, 0),
Array("", 1003405, 0),
Array("", 1003416, 0),
Array("", 1003417, 0),
Array("", 1003420, 0),
Array("", 1003421, 0),
Array("", 1003422, 0),
Array("", 1003430, 0),
Array("", 1003431, 0),
Array("", 1003432, 0),
Array("", 1003433, 0),
Array("", 1003435, 0),
Array("", 1003436, 0),
Array("", 1003458, 0),
Array("", 1003459, 0),
Array("", 1003460, 0),
Array("", 1003461, 0),
Array("", 1003462, 0),
Array("", 1003463, 0),
Array("", 1003482, 0),
Array("", 1003483, 0),
Array("", 1003484, 0),
Array("", 1003485, 0),
Array("", 1003486, 0),
Array("", 1003487, 0),
Array("", 1003492, 0),
Array("", 1003493, 0),
Array("", 1003494, 0),
Array("", 1003495, 0),
Array("", 1003496, 0),
Array("", 1003503, 0),
Array("", 1003506, 0),
Array("", 1003508, 0),
Array("", 1003509, 0),
Array("", 1003510, 0),
Array("", 1003516, 0),
Array("", 1003519, 0),
Array("", 1003520, 0),
Array("", 1003531, 0),
Array("", 1003533, 0),
Array("", 1003536, 0),
Array("", 1003538, 0),
Array("", 1003539, 0),
Array("", 1003541, 0),
Array("", 1003542, 0),
Array("", 1003543, 0),
Array("", 1003544, 0),
Array("", 1003545, 0),
Array("", 1003546, 0),
Array("", 1003547, 0),
Array("", 1003548, 0),
Array("", 1003549, 0),
Array("", 1003581, 0),
Array("", 1003586, 0),
Array("", 1003587, 0),
Array("", 1003588, 0),
Array("", 1003594, 0),
Array("", 1003595, 0),
Array("", 1003596, 0),
Array("", 1003597, 0),
Array("", 1003607, 0),
Array("", 1003636, 0),
Array("", 1003639, 0),
Array("", 1003640, 0),
Array("", 1003641, 0),
Array("", 1003642, 0),
Array("", 1003649, 0),
Array("", 1003650, 0),
Array("", 1003651, 0),
Array("", 1003652, 0),
Array("", 1003653, 0),
Array("", 1003666, 0),
Array("", 1003667, 0),
Array("", 1003675, 0),
Array("", 1003676, 0),
Array("", 1003677, 0),
Array("", 1003678, 0),
Array("", 1003696, 0),
Array("", 1003697, 0),
Array("", 1003698, 0),
Array("", 1003713, 0),
Array("", 1003727, 0),
Array("", 1003728, 0),
Array("", 1003742, 0),
Array("", 1003743, 0),
Array("", 1003748, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到时尚帽子店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}